export function GetRequest () {
  var url = decodeURI(window.location.search); //获取url中"?"符后的字串
  var theRequest = new Object();
  if (url.indexOf("?") !== -1) {
    var str = url.substr(1);
    var strs = str.split("&");
    for (var i = 0; i < strs.length; i++) {
      theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
    }
  }
  return theRequest;
}

export function getUrlParam (name) {
  let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  if (window.location.hash.indexOf("?") < 0) {
    return null;
  }
  let r = window.location.hash.split("?")[1].match(reg);
  if (r != null) return decodeURIComponent(r[2]);
  return null;
}
export function formatTime (date, x = '/', m) {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()
  if (m) {
    return [year, month, day].map(formatNumber).join(x)
  } else {
    return [year, month, day].map(formatNumber).join(x) + ' ' + [hour, minute, second].map(formatNumber).join(':')
  }
}
const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}
export function isOrigin () {
  const ua = window.navigator.userAgent.toLowerCase();
  if (ua.indexOf('micromessenger') > 0) {

    return 'WeiXIN';
  }
  if (ua.indexOf('alipayclient') > 0) {

    return 'Alipay';
  }
  if (ua.indexOf('unionpay/1.0') > 0) {
    return 'UnionPay'
  }
  return false;
}